"""
启动横幅显示模块
"""

import platform
import psutil
from datetime import datetime
import logging

logger = logging.getLogger(__name__)

def print_startup_banner(config: dict):
    """打印服务启动横幅信息"""
    try:
        # ASCII艺术字
        print("\n" + "="*80)
        print("""
██╗   ██╗██████╗ ██████╗  ██████╗    ██╗██╗  ██╗
██║   ██║██╔══██╗██╔══██╗██╔════╝   ██╔╝██║  ██║
██║   ██║██████╔╝██████╔╝██║       ██╔╝ ███████║
██║   ██║██╔══██╗██╔══██╗██║      ██╔╝  ╚════██║
╚██████╔╝██████╔╝██████╔╝╚██████╗██╔╝        ██║
 ╚═════╝ ╚═════╝ ╚═════╝  ╚═════╝╚═╝         ╚═╝

Universal Business Behavior Checker v4
        """)
        print("="*80)

        # 系统信息
        print("📊 系统信息")
        print("-" * 50)
        memory = psutil.virtual_memory()
        print(f"系统平台: {platform.system()} {platform.machine()} ({psutil.cpu_count()} cores)")
        print(f"内存使用: {memory.used // (1024*1024)}MB / {memory.total // (1024*1024)}MB")
        print(f"进程号  : {psutil.cpu_count()}")
        print(f"Python 版本  : Python {platform.python_version()}")
        print(f"启动时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
        print()

        # 服务信息
        print("🚀 服务信息")
        print("-" * 50)
        host = config['server']['host']
        port = config['server']['port']
        web_port = config['server']['web-port']
        ai_service = config['app_settings']['active_ai_service']
        print(f"API服务 : http://{host}:{port}")
        print(f"API端点 : http://{host}:{port}/api/v1/check-image")
        print(f"Web管理 : http://{host}:{web_port}")
        print(f"AI服务  : {ai_service}")
        print()

        # 操作提示
        print("💡 操作提示")
        print("-" * 50)
        print("• 按 Ctrl+C 优雅关闭服务")
        print(f"• 使用 POST http://{host}:{port}/api/v1/check-image 进行图片检查")
        print(f"• 访问 http://{host}:{web_port} 管理规则配置")
        print()

        print("✅ 服务已启动完成 - Powered by iSoftStone, 2025")
        print("="*80)
        print()

    except Exception as e:
        logger.warning(f"Failed to display startup banner: {e}")
